package com.nbsaas.boot.shop.rest.convert;

import com.nbsaas.boot.shop.data.entity.ShopBanner;
import com.nbsaas.boot.shop.api.domain.response.ShopBannerResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* -实体对象转化成响应对象
*/

public class ShopBannerResponseConvert  implements Converter<ShopBannerResponse,ShopBanner> {

    @Override
    public ShopBannerResponse convert(ShopBanner source) {
        ShopBannerResponse  result = new  ShopBannerResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getShop()!=null){
                        result.setShop(source.getShop().getId());
                    }

                    try {
                        if(source.getShopBannerPosition()!=null){
                            result.setShopBannerPositionName(source.getShopBannerPosition().getName());
                        }
                    } catch (Exception ignored) { }


                    try {
                        if(source.getShop()!=null){
                            result.setShopName(source.getShop().getName());
                        }
                    } catch (Exception ignored) { }

                    if(source.getStaff()!=null){
                        result.setStaff(source.getStaff().getId());
                    }
                    if(source.getShopBannerPosition()!=null){
                        result.setShopBannerPosition(source.getShopBannerPosition().getId());
                    }
        return result;
    }

}

